package com.hpin.fansea.service;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.hpin.fansea.R;
import com.hpin.fansea.adapter.ExpressAdapter;
import com.hpin.fansea.base.BaseActivity;
import com.hpin.fansea.pulltorefush.PullToRefreshBase;
import com.hpin.fansea.pulltorefush.PullToRefreshListView;

/**
 *
 * 快递服务
 * Created by Aaron on 15/9/15.
 */
public class ExpressActivity extends BaseActivity {

    private ExpressAdapter mAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_express);

        initWidget();
    }


    private void initWidget() {

        ImageView iv_left = (ImageView) findViewById(R.id.iv_left);
        TextView tv_title = (TextView) findViewById(R.id.tv_title);

        tv_title.setText(getResources().getString(R.string.express));

        iv_left.setOnClickListener(this);

        PullToRefreshListView plv_express = (PullToRefreshListView) findViewById(R.id.plv_express);

        mAdapter = new ExpressAdapter(this);
        plv_express.setAdapter(mAdapter);

        plv_express.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                ++position;

                Intent mIntent = new Intent(ExpressActivity.this, ExpressDetailActivity.class);
                startActivity(mIntent);

            }
        });


        plv_express.setMode(PullToRefreshBase.Mode.BOTH);

        plv_express.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {
            @Override
            public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {

            }

            @Override
            public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {

            }
        });

    }

    @Override
    public void widgetClick(View v) {

        switch (v.getId()) {

            case R.id.iv_left:

                finish();

                break;

        }
    }
}
